package com.usian.article.article.controller;

import com.usian.apis.service.article.ArticleHomeControllerApi;
import com.usian.article.article.service.ArticleHomeService;
import com.usian.common.article.ArticleConstans;
import com.usian.model.article.ArticleHomeDto;
import com.usian.model.article.ArticleInfoDto;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/article/api/v1/article")
public class ArticleHomeController implements ArticleHomeControllerApi {

    @Autowired
    private ArticleHomeService articleHomeService;

    @RequestMapping("load")
    @Override
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return articleHomeService.load(dto, ArticleConstans.LOADTYPE_LOAO_New);
    }

    @RequestMapping("loadMore")
    @Override
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return articleHomeService.load(dto, ArticleConstans.LOADTYPE_LOAO_MORE);
    }

    @RequestMapping("loadNew")
    @Override
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return articleHomeService.load(dto, ArticleConstans.LOADTYPE_LOAO_New);
    }

    @PostMapping("load_article_info")
    @Override
    public ResponseResult loadNewsByid(@RequestBody ArticleInfoDto dto) {
        return articleHomeService.loadNewsByid(dto);
    }
}
